package org.locker.netty;

import com.alibaba.ttl.TransmittableThreadLocal;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;

/**
 * 多租户 tenant_id存储器
 */
@Slf4j
public class NettyContext {

    private static ThreadLocal<Channel> currentTenant = new TransmittableThreadLocal<>();


    public static void setTenant(Channel channel) {
        currentTenant.set(channel);
    }

    public static Channel getChannel() {
        Channel channel = currentTenant.get();
        return channel;
    }

    public static void clear() {
        currentTenant.remove();
    }


}
